package de.karnik.dokobu.persistence;

import java.util.List;
import java.util.Vector;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.jdo.annotations.Element;

import com.google.appengine.api.datastore.Blob;
import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable="true")
public class Recipe {
 
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key key;
    @Persistent
	private String name;
    @Persistent
	private String instruction;
    @Persistent
	private Integer calories;
    @Persistent
    private RecipeCategory category;
	@Persistent(mappedBy = "recipe")
    @Element(dependent = "true")
	private List<RecipeIngredient> recipeIngredients;
	@Persistent 
    private Integer cookingTime;
	@Persistent
    private Boolean specialMeal;
	@Persistent
    private Blob image;
	@Persistent
    private String type;
	@Persistent
    private DoKoBuUser createdBy;
	@Persistent
    private DoKoBuUser lastmod;
     
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getInstruction() {
		return instruction;
	}
	public void setInstruction(String instruction) {
		this.instruction = instruction;
	}
	public Integer getCalories() {
		return calories;
	}
	public void setCalories(Integer calories) {
		this.calories = calories;
	}
	public RecipeCategory getCategory() {
		return category;
	}
	public void setCategory(RecipeCategory category) {
		this.category = category;
	}
	public List<RecipeIngredient> getRecipeIngredients() {
		return recipeIngredients;
	}
	
	public void addRecipeIngredient( RecipeIngredient recipeIngredient ) {
		if( this.recipeIngredients != null ) {
			this.recipeIngredients.add( recipeIngredient );
		} else {
			this.recipeIngredients = new Vector<RecipeIngredient>();
			this.recipeIngredients.add( recipeIngredient );
		}
	}
	
	public void setRecipeIngredients(List<RecipeIngredient> recipeIngredients) {
		this.recipeIngredients = recipeIngredients;
	}
	public Integer getCookingTime() {
		return cookingTime;
	}
	public void setCookingTime(Integer cookingTime) {
		this.cookingTime = cookingTime;
	}
	public Boolean getSpecialMeal() {
		return specialMeal;
	}
	public void setSpecialMeal(Boolean specialMeal) {
		this.specialMeal = specialMeal;
	}
	public Blob getImage() {
		return image;
	}
	public void setImage(Blob image) {
		this.image = image;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public DoKoBuUser getCreatedBy() {
		return createdBy;
	}
	public void setCreatedBy(DoKoBuUser createdBy) {
		this.createdBy = createdBy;
	}
	public DoKoBuUser getLastmod() {
		return lastmod;
	}
	public void setLastmod(DoKoBuUser lastmod) {
		this.lastmod = lastmod;
	}
	public Key getKey() {
		return key;
	}
        
   
	
}
